import { MENU_CHANNEL } from "~/config/enum.config";

export default {
  namespaced: true,
  state: {
    caseId: "",
    // caseNumber
    caseNo: "",
    //案件信息默认页面
    caseInfoActiveName: "essential-information",
    //通讯录默认页面
    addListActiveName: "telephone-book",
    //历史信息默认页面
    historyInfoActiveName: "follow-up-record",
    //法诉行动记录
    // legalActiveName: "legal-urge-history",
    // 是否添加了催记
    addRecordFlag: false,
    // 新加
    hiddenCaseList: false,
    hiddenAction: false,
    hiddenCollectionStatus: false,
    hiddenRemark: false,
    otherData: {},
    // 哪个菜单进入
    menuChannel: -1,
    // 客户信息默认页面
    customerInformationActiveName: '',
    personalNo: '',
    // 账户基本信息
    accountCaseInfo: {},
    // 客户类型
    personalType: '',
    // 电话列表点击的数据
    phoneClickData: {},
    // 客观码
    objectiveCode: [],
    // 留案原因码
    lleaveCode: [],
    // 客户姓名
    personalName: '',
    currentSavedStep: '',
    isRefreshFollupComponent: {}
  },
  mutations: {
    updateCaseId (state, data) {
      state.caseId = data;
    },
    updateCaseNo (state, data) {
      state.caseNo = data;
    },
    resetActiveName (state) {
      state.caseInfoActiveName = "essential-information";
      state.addListActiveName = "telephone-book";
      state.historyInfoActiveName = "follow-up-record";
      // state.legalActiveName = "legal-urge-history";
      state.customerInformationActiveName = state.personalType === 'ENTERPRISE' ? 'basic-information-company' : 'basic-information-customers'
    },
    updateAddListActiveName (state, data) {
      state.addListActiveName = data;
    },
    updateHistoryInfoActive (state, data) {
      state.historyInfoActiveName = data;
    },
    // updateLegalActive(state, data) {
    //   state.legalActiveName = data;
    // },
    updateCaseInfoActiveName (state, data) {
      state.caseInfoActiveName = data;
    },
    updateAddRecordFlag (state, flag: boolean) {
      state.addRecordFlag = flag;
    },

    updateCollectionSign (state, data) {
      state.collectionSign = data;
    },
    //
    updateHiddenCaseList (state, data) {
      state.hiddenCaseList = data;
    },
    updateHiddenRemark (state, data) {
      state.hiddenRemark = data
    },
    updateMenuChannel (state, menuChannel) {
      state.menuChannel = menuChannel;
    },
    updateHiddenAction (state, hidden) {
      state.hiddenAction = hidden;
      console.log('state.hiddenAction', state.hiddenAction);
    },
    updateHiddenCollectionStatus (state, hidden) {
      state.hiddenCollectionStatus = hidden;
    },
    updateOtherData (state, value: any) {
      state.otherData = value;
    },
    updatecustomerInformationActive (state, value) {
      state.customerInformationActiveName = value
    },
    updatePersonalNo (state, value) {
      state.personalNo = value
    },
    updateAccountCaseInfo (state, value) {
      state.accountCaseInfo = value
    },
    updatePersonalType (state, value) {
      state.personalType = value
    },
    updatePhoneClickData (state, value) {
      state.phoneClickData = value
    },
    updateObjectiveCode (state, value) {
      state.objectiveCode = value
    },
    updateLeaveCode (state, value) {
      state.leaveCode = value
    },
    updatePersonalName (state, value) {
      state.personalName = value
    },
    updateCurrentSavedStep (state, value) {
      console.log('updateCurrentSavedStep', value);
      state.currentSavedStep = value
    },
    setIsRefreshFollupComponent (state, data) {
      console.log('data', data);
      state.isRefreshFollupComponent = data
    }
  },
  getters: {
  },
  actions: {
    setCollectionData ({ commit }, { caseId, detailOptions }) {
      //设置caseId
      commit("updateCaseId", caseId);
      //重置活动区域
      commit("resetActiveName");
      commit("updateCaseNo", "");

      commit("updateHiddenCaseList", detailOptions.hiddenCaseList === true);

      commit("updateHiddenAction", detailOptions.hiddenAction === true);

      commit("updateHiddenCollectionStatus", detailOptions.hiddenCollectionStatus === true);
      commit('updateHiddenRemark', detailOptions.hiddenRemark === true)

      commit("updateOtherData", detailOptions.otherData || {});

      commit("updateMenuChannel", detailOptions.menuChannel);

      commit("updatePhoneClickData", {});

      commit('updateCaseNo', '')
      commit('updatePersonalNo', '')
    }
  }
};
